package com.qixiaobao.web.controller.system;

import com.qixiaobao.web.controller.core.controller.BaseController;
import com.qixiaobao.common.core.domain.AjaxResult;
import com.qixiaobao.system.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 字典
 * @Author yangxm
 * @Date 2025/6/16 13:07
 */
@RestController
@RequestMapping("/system/dict")
public class DictController extends BaseController {

    @Autowired
    private IDictService dictService;

    /**
     * @Description 供应商全称下拉
     * @Author yangxm
     * @Date 2025/6/17 17:31
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/supplyNameSelect")
    public AjaxResult supplyNameSelect(){
        List<Long> noPermissionSupplyIdList = checkPermission();
        return AjaxResult.success(dictService.selectSupplyNameSelect(noPermissionSupplyIdList));
    }

    /**
     * @Description 保单管理-待生效、在保中、已失效、退保已失效，所属供应商下拉
     * @Author yangxm
     * @Date 2025/6/18 9:08
     * @param gurantStatus 保单状态，7待生效，8在保中，9已失效，10退保已失效
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/insure/belongToSupplySelect/{gurantStatus}")
    public AjaxResult belongToSupplySelect(@PathVariable String gurantStatus){
        return AjaxResult.success(dictService.selectBelongToSupplySelect(gurantStatus));
    }

    /**
     * @Description 供应商简称下拉，与供应商全称联动
     * @Author yangxm
     * @Date 2025/6/18 9:08
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/supplyShortNameSelect")
    public AjaxResult supplyShortNameSelect(List<String> supplyNameList){
        List<Long> noPermissionSupplyIdList = checkPermission();
    	return AjaxResult.success(dictService.selectSupplyShortNameSelect(supplyNameList, noPermissionSupplyIdList));
    }

    /**
     * @Description 套餐字典
     * @Author yangxm
     * @Date 2025/6/18 9:08
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/mealNameSelect")
    public AjaxResult mealNameSelect(){
        List<Long> noPermissionSupplyIdList = checkPermission();
    	return AjaxResult.success(dictService.selectPermissionDictListByType("mealname", noPermissionSupplyIdList));
    }

    /**
     * @Description 伤残比例字典
     * @Author yangxm
     * @Date 2025/6/18 9:08
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/maimRatioSelect")
    public AjaxResult maimRatioSelect(){
        List<Long> noPermissionSupplyIdList = checkPermission();
        return AjaxResult.success(dictService.selectPermissionDictListByType("maimRatio", noPermissionSupplyIdList));
    }

    /**
     * @Description 职业类别字典
     * @Author yangxm
     * @Date 2025/6/18 9:08
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/jobTypeSelect")
    public AjaxResult jobTypeSelect(){
        List<Long> noPermissionSupplyIdList = checkPermission();
        return AjaxResult.success(dictService.selectPermissionDictListByType("jobtype", noPermissionSupplyIdList));
    }

    /**
     * @Description 投保周期字典
     * @Author yangxm
     * @Date 2025/6/18 9:08
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/insurePeriodSelect")
    public AjaxResult insurePeriodSelect(){
        List<Long> noPermissionSupplyIdList = checkPermission();
        return AjaxResult.success(dictService.selectPermissionDictListByType("insureperiod", noPermissionSupplyIdList));
    }

    /**
     * @Description 匹配后供应商简称下拉
     * @Author yangxm
     * @Date 2025/6/18 9:08
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/toSupplyShortNameSelect")
    public AjaxResult toSupplyShortNameSelect(){
        return AjaxResult.success(dictService.selectToSupplyShortNameSelect());
    }

    /**
     * @Description 增减员记录  -  所属供应商下拉
     * @Author yangxm
     * @Date 2025/6/24 9:07
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/addminus/belongToSupplySelect")
    public AjaxResult belongToSupplySelect(){
        return AjaxResult.success(dictService.selectAddminusBelongToSupplySelect());
    }

    /**
     * @Description 根据字典类型查询字典
     * @Author yangxm
     * @Date 2025/6/24 9:07
     * @param type 字典类型
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/dictByType/{type}")
    public AjaxResult dictByType(@PathVariable String type) {
        return success(dictService.selectDictListByType(type));
    }


    /**
     * @Description 付款单位下拉
     * @Author yangxm
     * @Date 2025/6/27 9:28
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/payCompanySelect")
    public AjaxResult payCompanySelect(){
        List<Long> noPermissionSupplyIdList = checkPermission();
        return AjaxResult.success(dictService.selectPayCompanySelect(noPermissionSupplyIdList));
    }

    /**
     * @Description 非直投结算管理，所属供应商下拉
     * @Author yangxm
     * @Date 2025/6/27 9:36
     * @return com.qixiaobao.common.core.domain.AjaxResult
     */
    @GetMapping("/nonDirect/belongToSupplySelect")
    public AjaxResult nonDirectBelongToSupplySelect(){
        return AjaxResult.success(dictService.selectNonDirectBelongToSupplySelect());
    }
}
